<?php

namespace addons\member\user\controller;

class MemberLog extends \web\user\controller\AddonUserBase{
    
    public function index(){
        return $this->fetch();
    }
    
    public function loadList(){
        $keyword = $this->_get('keyword');
        $filter = ' status = 0';
        if ($keyword != null) {
            $filter .= ' and  (username like \'%' . $keyword . '%\' or phone like \'%' . $keyword . '%\' or hash like \'%' . $keyword . '%\' )';
        }
        $m = new \addons\member\model\MemberEthLog();
        $total = $m->getDataTotal($filter);
        $rows = $m->getList($this->getPageIndex(), $this->getPageSize(), $filter);
        foreach ($rows as $key => $value) {
            $rows[$key]['times'] = date('Y-m-d H:i:s',$value['timestamp']);
        }
        return $this->toDataGrid($total, $rows);
    }
    
    public function btcindex(){
        return $this->fetch();
    }
    
    public function btcloadList(){
        $keyword = $this->_get('keyword');
        $filter = ' status = 0';
        if ($keyword != null) {
            $filter .= ' and (username like \'%' . $keyword . '%\' or phone like \'%' . $keyword . '%\' or txid like \'%' . $keyword . '%\' )';
        }
        $m = new \addons\member\model\MemberBtcLog();
        $total = $m->getDataTotal($filter);
        $rows = $m->getList($this->getPageIndex(), $this->getPageSize(), $filter);
        foreach ($rows as $key => $value) {
            $rows[$key]['times'] = date('Y-m-d H:i:s',$value['blocktime']);
        }
        return $this->toDataGrid($total, $rows);
    }

    public function usdtindex(){
        return $this->fetch();
    }
    
    public function usdtloadList(){
        $keyword = $this->_get('keyword');
        $filter = ' status = 0';
        if ($keyword != null) {
            $filter .= ' and (username like \'%' . $keyword . '%\' or phone like \'%' . $keyword . '%\' or hash like \'%' . $keyword . '%\' )';
        }
        $m = new \addons\member\model\MemberUsdtLog();
        $total = $m->getDataTotal($filter);
        $rows = $m->getList($this->getPageIndex(), $this->getPageSize(), $filter);
        foreach ($rows as $key => $value) {
            $rows[$key]['times'] = date('Y-m-d H:i:s',$value['timestamp']);
        }

        $count_total = $m->getMemberUsdtLogTotal($filter);
        return $this->toTotalDataGrid($total, $rows,$count_total);
    }

}


